﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NNOwnCardType : MonoBehaviour {
    public List<int> ownCards; //自己的牌
    public int CardType; //牌类型

    public UILabel typeLable;
    public UILabel timeLable;

    public List<UISprite> cards;
    public UILabel resultLable;
    public UISprite cardTypeSprit;

    int result;
    private string[] strType = { "无牛","牛一", "牛二", "牛三", "牛四", "牛五", "牛六", "牛七", "牛八", "牛九", "牛牛", "四炸", "五花牛", "五小牛" };
    private void Start()
    {
        typeLable.text = strType[CardType];
        for (int i = 0; i < 3; i++) {
            cards[i].spriteName = ownCards[i].ToString();
            int tempInt = ownCards[i] % 13;

            if (tempInt > 10)
            {
                result += 10;
            }
            else if (tempInt == 0) {
                result += 10;
            }
            else
            {
                result += tempInt;
            }
            resultLable.text = result.ToString();
            cardTypeSprit.spriteName = "cattle" + CardType;
        }
    }


    public float timeCount = 6f;
    private void Update()
    {
        timeCount -= Time.deltaTime;

        if (timeCount > 0)
        {
            int i = (int)timeCount;
            timeLable.text = i.ToString();
        }
        else if (timeCount < 0)
        {
            Destroy(gameObject);
        }
    }
}
